//
//  UIImageView+WebImage.swift
//  新浪微博
//
//  Created by 名品导购网MPLife.com on 2017/12/1.
//  Copyright © 2017年 sweet. All rights reserved.
//

import SDWebImage
extension UIImageView{
    //隔离SDWebImage设置图像函数
    func cz_setImage(urlStrin:String?,placeHoderImage:UIImage?,isAvatar:Bool = false) {
        //先处理URL
        guard let urlString = urlStrin, let url = URL(string: urlString) else {
            //设置占位图像
            image = placeHoderImage
            return
        }
        
        sd_setImage(with: url, placeholderImage: placeHoderImage, options: [], progress: nil) { [weak self] (image, _, _, _) in
           //完成回调 对图像进行判断，是否是头像
            if isAvatar{
                
               self?.image = image?.cz_avatarImage(size: self?.bounds.size, backColor: UIColor .white, lineColor: UIColor .clear)
            }
        }
        
    }
}






